home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 October / macformat-005.iso / Shareware City / Developers / Incognito 1.2ß2 src Folder / Incognito ƒ / init / Install.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-14  |  1.5 KB  |  89 lines  |  [TEXT/BROW]

  1.  
  2. #ifndef __OSUTILS__
  3. #include <OSUtils.h>
  4. #endif
  5.  
  6. #ifndef __RESOURCES__
  7. #include <Resources.h>
  8. #endif
  9.  
  10. #ifndef __EXCEPTIONS__
  11. #include <Exceptions.h>
  12. #endif
  13.  
  14. #ifndef __MEMORY__
  15. #include <Memory.h>
  16. #endif
  17.  
  18. #if __powerpc
  19.  
  20. long    gControlTrap;
  21. OSType    gGestaltSelector;
  22.  
  23. #define ShowINIT(x,y)
  24.  
  25. #else
  26.  
  27. #ifndef __GESTALTVALUE__
  28. #include <GestaltValue.h>
  29. #endif
  30. void MyControl(void);
  31. extern pascal void ShowINIT(short iconID, short moveX);
  32.  
  33. #endif
  34.  
  35. #ifndef __COMMON__
  36. #include "Common.h"
  37. #endif
  38.  
  39.  
  40. void INITInstall(void)
  41. {
  42.     long    oldControl;
  43.     Handle    theInitResource;
  44.     OSType    gestaltSelector;
  45.     long    gestaltInfo;
  46.     OSErr    error;
  47.     Handle    theStart;
  48.     
  49.     HLock(theStart = RecoverHandleSys((Ptr) INITInstall));
  50.     DetachResource(theStart);
  51.     oldControl = GetOSTrapAddress(0xA004);
  52.     gestaltSelector = Initialize(&gestaltInfo);
  53.     require(gestaltInfo, badinit);
  54.     
  55.     setGestalt(gestaltSelector);
  56.     setTrap(oldControl);
  57.  
  58. #if !__powerpc
  59.     error = NewGestaltValue(gestaltSelector, gestaltInfo);
  60.     nrequire(error, newgestaltval);
  61. #endif
  62.  
  63.     SetOSTrapAddress((UniversalProcPtr) MyControl, 0xA004);
  64.     
  65.     ShowINIT(kSuccessIcon, 40);
  66.     return;
  67. newgestaltval:    
  68.     {
  69.         MyGestaltPtr    pb = (MyGestaltPtr) gestaltInfo;
  70.         OriginalLinkPtr thePtr, pd;
  71.         
  72.         if (gestaltInfo)
  73.         {
  74.             pd = pb->trappedNames;
  75.             while (thePtr = pd->next)
  76.             {
  77.                 DisposePtr((Ptr) pd);
  78.             }
  79.             DisposePtr((Ptr) pd);
  80.             
  81.             DisposePtr((Ptr) pb->registeredNames);
  82.             DisposePtr((Ptr) pb);
  83.         }
  84.     }
  85. badinit:
  86.     HUnlock(theStart);
  87.     HPurge(theStart);
  88.     ShowINIT(kFailureIcon, 40);
  89. }